package com.aishang.shopback_2005.controller;

import com.aishang.shopback_2005.po.Product;
import com.aishang.shopback_2005.po.ProductExt;
import com.aishang.shopback_2005.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author 劉
 */
@RequestMapping("/product")
@RestController
public class ProductController {
    @Resource
    private ProductService productService;

    /**
     * 获取全部商品
     * @param productExt
     * @return
     */
    @RequestMapping("/getProducts")
    public PageInfo<Product> getProducts(@RequestBody ProductExt productExt){
        return productService.getProducts(productExt);
    }
    @RequestMapping("/addProduct")
    public String addProduct(@RequestParam("file")MultipartFile multipartFile,Product product){
        productService.addProduct(multipartFile,product);
        return "ok";
    }

}
